package cn.golxen.blog.rabbitMQ.producer;

import cn.golxen.blog.commons.utils.RabbitMQTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
@Async("taskExecutor")
public class Producer {
    @Autowired
    RabbitTemplate rabbitTemplate;

    public void essayProducer(RabbitMQTemplate rabbitMQTemplate){
        rabbitTemplate.convertSendAndReceive(rabbitMQTemplate.getExchange(),rabbitMQTemplate.getRoutingKey(),rabbitMQTemplate);
//        try {
//            Thread.sleep(1000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
//        System.out.println("前");
    }

    public void categoryProducer(RabbitMQTemplate rabbitMQTemplate){
        rabbitTemplate.convertSendAndReceive(rabbitMQTemplate.getExchange(),rabbitMQTemplate.getRoutingKey(),rabbitMQTemplate);
    }

    public void adminProducer(RabbitMQTemplate rabbitMQTemplate){
        rabbitTemplate.convertSendAndReceive(rabbitMQTemplate.getExchange(),rabbitMQTemplate.getRoutingKey(),rabbitMQTemplate);
    }


}
